# -*- coding: utf-8 -*-
# @Time : 2019/1/14 0014 11:22
# @Author : 犯傻中
# @File : case.py
# @Project : Python
# @title :
import requests, unittest, HTMLTestRunner,random,re
from woniubossV2 import read_data


class student_manage(unittest.TestCase):
    @classmethod
    def setUpClass(cls):
        cls.ses = requests.session()
        c = cls.ses.post(url='http://192.168.2.155:8080/WoniuBoss2.5/log/userLogin',
                         data={'userName': 'wncd005', 'userPass': 'woniu123', 'checkcode': '0000'})
        # print('-----')
        # print(c.cookies)
        # print('-----')

    @classmethod
    def tearDownClass(cls):
        print("")

    def test_Stagevaluation(self):
        self.w=read_data.read_excel().excel_login(r"data.xlsx",1)
        print()
        result=self.decode01()
        if result==True:
            note=str(random.randint(1,99999999999999999))
            url='http://192.168.2.155:8080/WoniuBoss2.5/student/saveScore'
            data={"pe.phase_exam_student_id":"846",
                  "pe_orientation1":"",
                  "pe_class1":"",
                  "pe.phase":"专业第一阶段",
                  "pe.score":"88",
                  "status":"1",
                  "pe.comment":"%s"%note}
            # headers={"Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"}
            c=self.ses.post(url=url,data=data)
            self.assertEqual(c.text,"success")
        else:
            print("未解密")
    #
    # def test_demotion(self):
    #     result = self.decode01()
    #     if result == True:
    #         url = 'http://192.168.2.155:8080/WoniuBoss2.5/student/updateRepeat'
    #         data = {"pe.phase_exam_student_id":"843","old_re_orientation":"测试","old_re_class":"WNCDC006","orientation":"测试","class_no":"WNCDC035"}
    #         c = self.ses.post(url=url, data=data)
    #         print(c.text)
    #     else:
    #         print("未解密")
    #
    #
    #
    #
    def decode01(self):
        url = 'http://192.168.2.155:8080/WoniuBoss2.5/student/queryPhaseExamStuByInfo'
        data={"pageSize":"10","pageIndex":"1","stuClass":"","orientation":"","stuName":""}
        c=self.ses.post(url=url,data=data)
        print(c.text)
        if '****' in c.text:
            result=False
        else:
            result=True

        return result
    # def test_query_class(self):
    #     url = 'http://192.168.2.155:8080/WoniuBoss2.5/student/queryStuOfClassByInfo'
    #     data={"pageSize":"1000000000","pageIndex":"1","stuName":""}#当前页面的条数不能超过100亿
    #     c = self.ses.post(url=url, data=data)
    #     all=re.findall(r'"student_id":(.*?),"',c.text)
    #     print(all)
    #     print(len(all))
    # def test_driveintoclass(self):
    #     url = 'http://192.168.2.155:8080/WoniuBoss2.5/student/allocate'
    #     data = {"stuIdArr%5B%5D":"721","stuClass":"WNCDC035","orientation":"测试"}
    #     c = self.ses.post(url=url, data=data)
        # print(c.text)
    # def test_student006(self):
    #     result = self.ses.post(url="http://192.168.2.155:8080/WoniuBoss2.5/student/saveNewInfo",
    #                          # Content-Type: multipart/form-data
    #                          data={
    #                              'stu.student_id':(None, '1274'),
    #                              'stu.student_name':(None, "夏洪金"),
    #                              'stu.student_no':(None, "WNCD201710002"),
    #                              'stu.class_no':(None, 'WNCDC034'),
    #                              'stu.tel':(None, "13939206533"),
    #                              'stu.sex':(None, "女"),
    #                              'stu.status':(None, '在校学习'),
    #                              'stu.email':(None, ''),
    #                              'stu.QQ':(None, '0'),
    #                              'stu.source':(None, '智联招聘'),
    #                              'stu.emergency_person':(None, '18510295804'),
    #                              'stu.emergency_tel':(None, '13350022197'),
    #                              'stu.education':(None, '本科'),
    #                              'stu.major':(None, '应用化学'),
    #                              'stu.IDnumber':(None, "510632198808094455"),
    #                              'stu.graduation_time': (None, '2016-05-12'),
    #                              'stu.age':(None,'23')
    #                              })
    #     print(result.text)
        # # print(result.request.body)
        # print(data['name'])
        # # print(data['number'])
        # # print(result.request.headers)
        # print(result.text)
        # self.assertIn(data['expect'], result.text)


if __name__ == '__main__':
    unittest.main()
